package com.imu.constant;

import java.math.BigDecimal;

/**
 * Created by Administrator on 2017/3/15.
 */
public interface Constant
{
	public static final long SESSION_TIMEOUT = 1296000;//会话超时时间
	
	public static final Integer EXECUTORS_COUNT = 10;//异步线程数

	public static final Integer ACODE_LEN = 6; 	//验证码长度
	
	public static final int POOL_COUNT = 10;    	//线程个数
	
	public static final int POOL_DELAYED = 60;    	//线程延迟时间秒
	
	public static final String SEQ = "seq";		//编号序列
	
	public static final String SUCCESS = "SUCCESS";//成功
	
	public static final String DEF_CODE = "123456"; //默认验证码
	
	public static final String FAIL = "FAIL";//失败
	
	public static final String PRO_NAME = "XCHAT"; //产品名称
	
	public static final String MQ_PAY_TAG = "XCHAT_PAY";
	
	public static final Integer ENABLE = 1;//启用
	
	public static final Integer UNABLE = 0;//关闭
	
	public static final Integer YES =  1; //是
	
	public static final Integer NO  = 0;  //否

	public static final Integer DEL = -1;  //删除
	
	public static final Integer DEF =  0; //默认

	public static final Integer SUC =  1; //成功
	
	public static final Integer FAI = -1; //失败
	
	public static final String PROFILE_KEY = "u:profile"; //用户基础信息

	public static final String SYS_DICT = "sys:dict"; //系统字典缓存
	
	public static final String SYS_GIFT_SET = "sys:gift:set"; //系统礼物缓存
	
	public static final String SYS_GIFT_HASH = "sys:gift:hash"; //系统礼物缓存

	public static final String VIR_GOODS_FIX = "xin_coin_"; 		//虚拟商品ID前缀
	
	public static final String VIR_GOODS_SET = "sys:goods:set"; 	//系统商品缓存
	
	public static final String VIR_GOODS_HASH = "sys:goods:hash"; 	//系统商品缓存
	
	public static final String USER_TAG_HASH = "u:tag:"; 	//用户标签缓存

	public static final String USER_PURSE_KEY = "u:purse"; 		//用户财富钱包缓存
	
	public static final String USER_RPURSE_KEY = "u:rpurse"; 	//用户财富钱包缓存
	
	public static final String USER_ANALY_KEY = "u:analy"; 		//用户财富统计数据

	public static final String MIND_DAY_SET = "rich:mind:day:"; //心意财富最近15天统计

	public static final String ATTR_DAY_SET = "rich:attr:day:"; //吸引财富最近15天统计
	
	public static final String MOBILE = "m"; //移动端
	
	public static final String PC = "p"; //PC端
	
	public static final String SESSION_FIX = "s:"; //session 开头
	
	public static final Long INV_MIN_CODE = 123456L;
	
	public static final float SCALE = 0.7f;
	
	public static final Long MIN_WITH_DRAW = 100000L; //最小提现金额
	public static final Long MONEY_SCALE = 10L; 	  //金额跟虚拟积分比例
	public static final float WD_SCALE = 0.7f;

	public static final int SYS_GRADE = -14; 	//等级最近15天合
	public static final int SYS_WEEK  = -6; 	//等级最近7天合

	public static final int GRADE_DE = 0; 	 //等级状态 未激活
	public static final int GRADE_EN = 1; 	 //等级状态 激活
	
	public static final String BITCOIN_HEIGHT = "bitcoin-height"; //上一次请求bitcoin的区域高度
	
	public static final Long TRANSFER_OUT_ID = -100L; //转账给外部人默认用户id
	
	public static final String MONEY_PACKAGE_CONNECT_ERROR = "-100"; //钱包连接异常
	public static final String MONEY_PACKAGE_CONNECT_OTHER_ERROR = "-1"; //钱包其他异常
	
	public static final String BITCOIN_SCHEDULE_NAME = "bitcoin_name";//bit定时任务

	public static final String TRANSFER_SEND = "send";//转出

	public static final String TRANSFER_RECEIVE = "receive";//转出
	
	public static final BigDecimal DEFAULT_RATE = (new BigDecimal("0.001")).setScale(3,BigDecimal.ROUND_DOWN);//转出交易费最低值
	
	public static final String MONEY_ADDR_KEY = "MONEY_ADDR";//缓存中与用户的手机号绑定

	public static final String CORE_MONEY_KEY = "core_money_address";//核心钱包的key

	public static final String CORE_MONEY_SUFFIX = "core_money";//缓存中核心钱包地址与用户id的key的后缀

	public static final String CORE_MONEY_TRANS_EXPIRE = "CORE_MONEY_TRANS_EXPIRE";//核心钱包交易过期的缓存key

	public static final String CORE_MONEY_USER_KEY = "core_money_user_key";
	public static final String USER_CORE_MONEY_KEY = "user_core_money_key";

	public static final String OK = "OK";

	public static final String TRANS_CONSUMER_TIME = "trans:consumer:time";

	public static final BigDecimal DAY_MONEY = new BigDecimal(100); //每天转的最大imu数量

	public static final int MIN_ADDRESS_LEN = 27; //核心钱包最短地址

	public static final int MAX_ADDRESS_LEN = 34; //核心钱包最长地址

	//后面补充18个0
	//public static final String YTF_MONEY_SUFFIX = "1" + String.format("%1$0"+17+"d",0);

	public static final String YTFCOIN_SCHEDULE_NAME = "ytfcoin_name";//以太坊定时任务

	public static final  String YTFCOIN_HEIGHT = "ytfcoin-height";//上一次青铜以太坊的区域高度

	public static final String IMU_CONTRACT_ADDRESS = "0xEDc6cca4cd34e2164aC7C3eD566837D7b7A5e433"; //"0xEDc6cca4cd34e2164aC7C3eD566837D7b7A5e433";//imu智能合约地址

	public static final String  IMU_ABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"version\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"balance\",\"type\":\"uint256\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"},{\"name\":\"_extraData\",\"type\":\"bytes\"}],\"name\":\"approveAndCall\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"remaining\",\"type\":\"uint256\"}],\"type\":\"function\"},{\"inputs\":[{\"name\":\"_initialAmount\",\"type\":\"uint256\"},{\"name\":\"_tokenName\",\"type\":\"string\"},{\"name\":\"_decimalUnits\",\"type\":\"uint8\"},{\"name\":\"_tokenSymbol\",\"type\":\"string\"}],\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"_spender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"}]";

	//以太坊前面需要加上0x
	public static final String YTF_PERFIX = "0x";

	public static final String YTF_16_0 = YTF_PERFIX + "0";

	public static final String MONEY_TO_YTF = "1000000000000000000"; //10e18

	public static final String YTF_INPUT_PREFIX = "0x0"; //只有IMU国际钱包转出，才会是该值

	public static final String UNLOCK_TIME = "0x00000000000000000000000000000078";//120毫米

	//IMU国际钱包大钱包地址 向外转账的时候，from填写该地址
	public static final String YTF_FROM = "0x7ebea9f48f4ef959d3830d2063e11d6f18d61880";

	public static final String REDIS_CFG_KEY = "sys:config";
	public static final String PRI_USER_KEY = "PRI_USER_KEY";
	public static final String SYS_USER = "u:profile";
	public static final String SYS_USER_FUND = "u:fund";
	
	//  -- 函数：心意扣费
	//  -- 成功，则返回1，如果不成功，则返回空
	//  -- 函数：返回-9钱余额不足
	//  -- 函数：返回-1没找到钱包
    //  -- 参数值：KEYS[1] 钱包缓存KEY
    //  -- 参数值：ARGV[1] 用户ID,
    //  -- 参数值：ARGV[2] 充值心意  
    //  -- 参数值：KEYS[3] 奖励心意
    public static final String MIND_SCRIPT  = "if redis.call('hexists', KEYS[1], ARGV[1]) ~= 1 then\n"
	                                     	+ "return -1\n"
                                            + "else\n"
                                            + "local purse = redis.call('hget', KEYS[1], ARGV[1]);\n"
                                            + "if (purse ~= nil and purse) then\n"
                                            + "local x = cjson.decode(purse);\n"
                                            + "if (0 >= tonumber(x['reMind']) and 0 >= tonumber(x['giveMind'])) then\n"
	                                     	+ "return -9\n"
                                            + "end\n"
                                            + "if (0 < tonumber(ARGV[2])) then\n"
                                            + "x['reMind'] = tonumber(x['reMind']) - tonumber(ARGV[2])\n"
                                            + "end\n"
                                            + "if (0 < tonumber(ARGV[3])) then\n"
                                            + "x['giveMind'] = tonumber(x['giveMind']) - tonumber(ARGV[3])\n"
                                            + "end\n"
                                            + "local re = cjson.encode(x);\n"
                                            + "redis.call('hset', KEYS[1], ARGV[1], re);\n"
                                            + "return 1;\n"
                                            + "end\n"
                                            + "end\n"
                                            + "return nil";
    
    //  -- 函数：吸引扣费
	//  -- 成功，则返回1，如果不成功，则返回空
	//  -- 函数：返回-8普通吸引值不足
	//  -- 函数：返回-7吸引值不能低于100000
	//  -- 函数：返回-1没找到钱包
    //  -- 参数值：KEYS[1] 钱包缓存KEY
    //  -- 参数值：ARGV[1] 用户ID,
    //  -- 参数值：ARGV[2] 普通 吸引值  
    //  -- 参数值：KEYS[3] 奖励 吸引值
    public static final String ATTRA_SCRIPT = "if redis.call('hexists', KEYS[1], ARGV[1]) ~= 1 then\n"
	                                     	+ "return -1\n"
                                            + "else\n"
                                            + "local purse = redis.call('hget', KEYS[1], ARGV[1]);\n"
                                            + "if (purse ~= nil and purse) then\n"
                                            + "local x = cjson.decode(purse);\n"
                                            + "if (70000 > tonumber(x['reAttract'])) then\n"
	                                     	+ "return -8\n"
                                            + "end\n"
                                            + "if (100000 > (tonumber(x['reAttract']) + tonumber(x['giveAttract']))) then\n"
	                                     	+ "return -7\n"
                                            + "end\n"
                                            + "if (0 < tonumber(ARGV[2])) then\n"
                                            + "x['reAttract'] = tonumber(x['reAttract']) - tonumber(ARGV[2])\n"
                                            + "end\n"
                                            + "if (0 < tonumber(ARGV[3])) then\n"
                                            + "x['giveAttract'] = tonumber(x['giveAttract']) - tonumber(ARGV[3])\n"
                                            + "end\n"
                                            + "local re = cjson.encode(x);\n"
                                            + "redis.call('hset', KEYS[1], ARGV[1], re);\n"
                                          + "return 1;\n"
                                            + "end\n"
                                            + "end\n"
                                            + "return nil";
    
    interface User
	{
    	//状态 正常
    	public static final Integer ACTIVE = 1;
		//状态 禁用
    	public static final Integer SUSPENDED = 0;
		//已删除
    	public static final Integer DEL = -1;
		//在线
    	public static final Integer ONLINE = 1;
		//离线
    	public static final Integer OFFLINE = 0;
		//在直播
    	public static final Integer ONLIVE = 1;
		//未直播
    	public static final Integer OFFLIVE = 0;
		//首次登陆
    	public static final Integer LONGIN_F = 1;
		//非首次
    	public static final Integer LONGIN_D = 0;
    	//非推荐注册
    	public static final Integer INV_DEF = -1;
    	//推荐注册
		public static final Integer INV_REG  = 0;
		//推荐领奖
		public static final Integer INV_SUC  = 1;
		//未认证
		public static final Integer AUTH_DEF =  0;
		//认证中
		public static final Integer AUTH_SUC =  1;
		//认证通过
		public static final Integer AUTH_PAS =  2;
		//认证失败
		public static final Integer AUTH_FAI = -2;
		//默认性别
		public static final Integer GENDER = -1;
		//默认性别 0女
		public static final Integer WOMAN = 0;
		//默认性别1男
		public static final Integer MAN = 1;
		//默认最大等级权限
		public static final Integer MAX_RANK = 0;
		//昵称前缀
		public static final String NICK_FIX = "x"; 	
		//才艺被点播
		public static final Integer TAG_CLICKED = 0;
		//才艺点播
		public static final Integer TAG_CLICK = 1;
		//才艺次数
		public static final Long DEF_COUNT = 1l;
		//送出礼物
		public static final Integer GIFT_SEND = 1;
		//收到礼物
		public static final Integer GIFT_RECE = 0;
	}
    
    interface WithDraw
	{
    	//成功
    	public static final Integer SUC = 1;
		//处理中 Handle
    	public static final Integer HANDLE = 0;
		//失败
    	public static final Integer FAI = -1;
		//提现最小金额
    	public static final Long MIN = 100000L;
    	
	}
    
    interface ScheduleStatus{
    	public static final Integer FAIL = 0;
    	public static final Integer SUCCESS = 1;
    }

	interface UserLog
	{
		//操作状态
		//1 用户状态禁用
		public static final Integer USER_LOCK = 1;
		//2用户状态解禁
		public static final Integer USER_UNLOCK = 2;
		//3 转账状态禁用
		public static final Integer ZZ_LOCK = 3;
		//4 转账状态解禁
		public static final Integer ZZ_UNLOCK = 4;
		//5.短信手机变更
		public static final Integer PHONE_CHANGE = 5;
		//6 合并资金
		public static final Integer MONEY_CHANGE = 6;


	}
}
